package com.aac.framwork.aacframwork.webservice;

import io.reactivex.annotations.NonNull;

import static com.aac.framwork.aacframwork.repository.datas.AppConstent.ResStatus.ERROR;
import static com.aac.framwork.aacframwork.repository.datas.AppConstent.ResStatus.LOADING;
import static com.aac.framwork.aacframwork.repository.datas.AppConstent.ResStatus.SUCCESS;

public class Resource<T> {

    @NonNull
    public final int status;

    @NonNull
    public final T data;

    @NonNull
    public final String message;

    public Resource(int status, T data, String message) {
        this.status = status;
        this.data = data;
        this.message = message;
    }

    public static <T> Resource<T> success(@NonNull T data) {
        return new Resource<>(SUCCESS, data, "success");

    }

    public static <T> Resource<T> error(String msg, @NonNull T data) {
        return new Resource<>(ERROR, data, "error");
    }

    public static <T> Resource<T> loading(@NonNull T data) {
        return new Resource<>(LOADING, data, "error");
    }
}
